<% 
	var headContent = {
	include("/pages/template/head.html"){}
%>

<script type="text/javascript">
var oper;

$(function() {
	// 头像展示
	$('[name="model.title_url"]').change(function(){
		var pic = $(this).val() ;
		if(pic == '') {
			pic = 'static/images/user/user.png';
		}
		
		$('#title_pic').attr('src',pic);
	});
	
	
	// 页面方法
	oper = {
		form : document.form1,
		list : function() {
			var url = 'admin/person';
			this.form.action = url;
			this.form.submit();
		}
	};
});

function oper_save(){
	if($('[name="old_password"]').val()==''){
		alert('密码不能为空');
		return;
	}
	
	jQuery.ajax({
		type:'POST',
		url:'admin/person/save',
		data:$("form").serialize(),
		success:function(data){
			if(data.status==1){
				alert('保存成功');
			} else {
				alert('保存失败：'+data.msg);
			}
			$('[name="old_password"]').val('');
			$('[name="new_password"]').val('');
			$('[name="new_password2"]').val('');
		},
		error:function(html){
			var flag = (typeof console != 'undefined');
			if(flag) console.log("服务器忙，提交数据失败，代码:" +html.status+ "，请联系管理员！");
			alert("服务器忙，提交数据失败，请联系管理员！");
		}
	});
}


/**
 * 设置主题
 */
function oper_theme(theme){
	jQuery.ajax({
		type:'POST',
		url:'admin/person/theme/'+theme,
		success:function(data){
			if(data.status==1){
				if(typeof oper=='undefined' && typeof form=='undefined') {
					Alert('设置成功,请刷新页面');
				} else {
					Alert('设置成功.',function(){
						if(typeof oper!='undefined'&&typeof oper.list!='undefined'&&oper.list instanceof Function) {
							oper.list()
						} else if(typeof form!='undefined'&&form.search[0].getAttribute("onclick")!=null){
							form.search[0].click();
						};
					});
				}
			} else {
				Alert('保存失败：'+data.msg);
			}
		},
		error:function(html){
			var flag = (typeof console != 'undefined');
			if(flag) console.log("服务器忙，提交数据失败，代码:" +html.status+ "，请联系管理员！");
			alert("服务器忙，提交数据失败，请联系管理员！");
		}
	});
}
</script>

<%
};

var bodyContent = {
%>

<!-- 菜单 -->
<% include("/pages/template/menu.html"){} %>

<div class="container">
	
	<div class="row">
		<div class="col-md-12">
		
		<div class="panel panel-default">
		  <div class="panel-heading">
			<h3 class="panel-title">个人信息</h3>
		  </div>
		   <div class="panel-body">
				<form class="form-horizontal" name="form1" action="" method="post">
						<input type="hidden" name="model.userid" value="${model.userid}" />
						
						<!-- 主题 -->
						<div class="form-group">
						    <label for="username" class="col-sm-2 control-label">主题设置</label>
						    <div class="col-sm-10">
						    	<div class="dropdown" >
								  <button class="btn btn-link dropdown-toggle" title="主题" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
								    <span class="glyphicon glyphicon-th-list"></span> ${session.session_user.theme!'default'} <span class="caret"></span>
								  </button>
								  <ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
								    <li><a href="#" onclick="oper_theme('default');return false;">default（白色）</a></li>
								    <li><a href="#" onclick="oper_theme('inverse');return false;">inverse（黑色）</a></li>
								    <li><a href="#" onclick="oper_theme('flat-ui');return false;">flat-ui（绿色）</a></li>
								    <li><a href="#" onclick="oper_theme('flat');return false;">flat（绿色）</a></li>
								  </ul>
								</div>
						    </div>
						  </div>
						
						 <div class="form-group">
						    <label for="username" class="col-sm-2 control-label">登录名</label>
						    <div class="col-sm-10">
						    	${model.username!''}
						    </div>
						  </div>
						  <div class="form-group">
						    <label for="realname" class="col-sm-2 control-label">昵称</label>
						    <div class="col-sm-10">
						      <input name="model.realname" class="form-control" id="realname" 
						      	value="${model.realname!''}" placeholder="昵称">
						    </div>
						  </div>
						  
							<div class="form-group">
							    <label for="old_password" class="col-sm-2 control-label">原始密码</label>
							    <div class="col-sm-10">
							      <input name="old_password" type="password"class="form-control" id="old_password" placeholder="原始密码">
							    </div>
							  </div>
							  <div class="form-group">
							    <label for="new_password" class="col-sm-2 control-label">新密码</label>
							    <div class="col-sm-10">
							      <input name="new_password" type="password"class="form-control" id="new_password" placeholder="新密码">
							    </div>
							  </div>
							  <div class="form-group">
							    <label for="new_password2" class="col-sm-2 control-label">重复密码</label>
							    <div class="col-sm-10">
							      <input name="new_password2" type="password" class="form-control" id="new_password2" placeholder="重复密码">
							    </div>
							  </div>
							
							<div class="form-group">
							    <label for="email" class="col-sm-2 control-label">email</label>
							    <div class="col-sm-10">
							    	<input name="model.email" class="form-control" type="email" id="email" 
							    		value="${model.email!''}"  placeholder="Email">
							    </div>
							  </div>
							<div class="form-group">
							    <label for="tel" class="col-sm-2 control-label">手机号</label>
							    <div class="col-sm-10">
							      <input name="model.tel" type="text" class="form-control" id="tel" 
							      	value="${model.tel!''}" placeholder="手机号">
							    </div>
							  </div>
							  <div class="form-group">
							    <label for="remark" class="col-sm-2 control-label">备注</label>
							    <div class="col-sm-10">
							    	<textarea rows="3" cols="30" class="form-control" id="remark"
									 name="model.remark" placeholder="备注">${model.remark!''}</textarea>
							    </div>
							  </div>
							 
						  
						  
						   <div class="form-group">
							    <div class="col-sm-offset-2 col-sm-10">
							      <input type="button" value="保 存"  class="btn btn-primary" onclick="oper_save();"/>
										&nbsp;&nbsp;&nbsp;&nbsp;
								  <input type="reset" value="重 置"  class="btn btn-default" />
							    </div>
							</div>
							<div class="form-group">
							    <div class="col-sm-offset-2 col-sm-10">
							      1. 修改基本信息需要输入原始密码。<br>
								  2. 修改密码需要输入原始密码、新密码。
							    </div>
							</div>
						
						</form>
				
				</div>
			</div>
		</div>
		
	</div>
</div>

						
<%}; %>

<% layout("/pages/template/_layout.html",{head:headContent,body:bodyContent}){ %>
<%} %>
